import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

class Sort {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        if(nums1 ==null && nums2==null){
            return 0;
        }
        //排序合并两个数组；使用归并排序
        int i =0;
        int j =0;
        int k =0;
        double a;
        int[] n3= new int[nums1.length+nums2.length];
        //当 nums1，和nums2都还存在值的时候
        while (i < nums1.length && j <nums2.length){
            //当nums1的值小的时候，i++ k++
            if(nums1[i] <= nums2[j]){
                n3[k++] = nums1[i++];
            }
            else{
                n3[k++] = nums2[j++];
            }
        }
        //当nums2不存在元素的时候
        while (i<nums1.length){
            n3[k++] =nums1[i++];
        }
        //当nums1不存在元素的时候
        while (j<nums2.length){
            n3[k++] =nums2[j++];
        }
        if(n3.length%2 != 0 ){
            a = n3[n3.length/2]*1.0;
        }else{
            i = n3.length/2;
            j = i-1;
            //除数得为2.0才可以转换成double类型
            a = (n3[i]+n3[j])/2.0;
        }
        return a;
    }
}

public class MainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
            return new int[0];
        }

        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for(int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }
        return output;
    }

    public static String doubleToString(String input) {
        return new DecimalFormat("0.00000").format(input);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums1 = stringToIntegerArray(line);
            line = in.readLine();
            int[] nums2 = stringToIntegerArray(line);

            double ret = new Sort().findMedianSortedArrays(nums1, nums2);

            String out = doubleToString(String.valueOf(ret));

            System.out.print(out);
        }
    }
}
